/********************************************
* Copyrigt (C) rumi
* Module: drv_pincontrol.c
*********************************************/
#include "drv_pincontrol.h"

// static const char *TAG = "drv_pincontrol.c";

/**************************Init Area*********************************/


static uint8_t Drv_WritePin(PinConfig_DrvDef *pin,uint8_t state)
{
    gpio_set_level((gpio_num_t)pin->PinNum, state);
    return 1;
}

static uint8_t Drv_ReadPin(PinConfig_DrvDef *pin)
{
    uint8_t state = gpio_get_level((gpio_num_t)pin->PinNum);
    return state;
}

static uint8_t Drv_Init_GPIO()
{
    Bsp_Init_ALL_GPIO();
    return 1;
}

/*******************************************************************/
uint8_t Drv_IO_Control(PinConfig_DrvDef *ioDevice,uint8_t type, uint8_t state)
{
    switch ((PIN_CTRL_EnumDef)type)
    {
        case E_PIN_INIT:
            Drv_Init_GPIO();
            break;
        case E_PIN_READ:
            return Drv_ReadPin(ioDevice);
            break;
        case E_PIN_WRITE:
            Drv_WritePin(ioDevice,state);
            break;
        default:
            break;
    }
    return 0;
}


/********************************************
 * End of file
*********************************************/
